<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/v2/console/common/taglibs.jsp"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>十方天资官网后台管理系统</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<link rel="stylesheet" href="${path}/v2/console/css/base.css">
<link rel="stylesheet" href="${path}/v2/console/css/style.css">
<script src="${path}/v2/console/js/jquery-1.9.1.min.js"></script>
</head>
<body>
	<div id="wrapper">
		<div class="main">
			<div class="main-right">
				<div class="column-name">
					<h2>
						栏目管理 > <b>新建栏目</b>
					</h2>
				</div>
				<div class="form">
					<form id="nodetypeform" name="nodetypeform" action="${pageContext.request.contextPath}/siteNode/addSiteNode.html" method="post">
						<input type="hidden" name="parentId" value="${parentId }"/>
						<div class="form-item">
							<div class="form-name">栏目名称:</div>
							<div class="form-input">
								<input type="text" id="" name="name" class="input" value="">
								<div class="clearfix"></div>
								<div class="form-error red"></div>
							</div>
						</div>
						<div class="form-item" id="goodstype">
							<div class="form-name">分类：</div>
							<div class="form-input">
								<select id="typeId" name="typeId" class="input">
									<c:forEach var="nodetype" items="${nodetypes}">
										<option value="${nodetype.id}">${nodetype.name}</option>
									</c:forEach>
								</select>
								<div class="clearfix"></div>
								<div class="form-msg hide" style="color: red;"></div>
							</div>
						</div>
						<!-- <div class="form-item" id="goodstype">
							<div class="form-name">首页头条：</div>
							<div class="form-input">
								<select id="isTop" name="isTop" class="input">
									<option value="0" >否</option>
									<option value="1" >是</option>
								</select>
								<div class="clearfix"></div>
								<div class="form-msg hide" style="color: red;"></div>
							</div>
						</div> -->
						<div class="form-item">
							<div class="form-name">排序号:</div>
							<div class="form-input">
								<input type="text" id="" name="ord" class="input"
									value="">
								<div class="clearfix"></div>
								<div class="form-error red"></div>
							</div>
						</div>
						<!-- <div class="form-item" id="goodstype">
								<div class="form-name">是否导航显示：</div>
								<div class="form-input">
									<select id="isDisplay" name="isDisplay" class="input">
										<option value="0" >否</option>
										<option value="1" >是</option>
									</select>
									<div class="clearfix"></div>
									<div class="form-msg hide" style="color: red;"></div>
								</div>
						</div> -->
						<%-- <c:if test="${parentId==0 }"> --%>
							<div class="form-item" id="goodstype">
								<div class="form-name">是否直接跳转：</div>
								<div class="form-input">
									<select id="isRedirect" name="isRedirect" class="input">
										<option value="0" >否</option>
										<option value="1" >是</option>
									</select>
									<div class="clearfix"></div>
									<div class="form-msg hide" style="color: red;"></div>
								</div>
							</div>
							<div class="form-item">
							<div class="form-name">模板类型:</div>
							<div class="form-input">
								<input type="text" id="redirectUrl" name="redirectUrl" class="input" value="">
								<div class="clearfix"></div>
								<div class="form-error red"></div>
							</div>
						</div>
						<%-- </c:if> --%>
						<input type="hidden" name="imageUrl" id="imageUrl" >
						<!-- <input type="submit" value="保  存" class="btn w144" /> -->
					</form>
					<form id="firstPicForm" onsubmit="return false;">
						<div class="form-item form-item01">
							<div class="form-name">标题图片<span style="color:red;"></span>：</div>
							<div class="form-input">
								<input type='text' id='textfield' class='input' /> 
								<input type="file" name="img" class="file input" id="fileField"  onchange="document.getElementById('textfield').value=this.value" />
    							<button class="btn-blue" onclick="uploadFirstImage()">上传图片</button>
    							<div class="clearfix"></div>
    							<div id="firstPic" class="form-img hide">
    								<img src="${path}/v2/console/images/back.jpg" alt="">
    							</div>
							</div>
						</div>
					</form>
					<button type="button" class="btn w144" onclick="add()">保  存</button>
				</div>
			</div>
		</div>
	</div>
<script type="text/javascript">
function uploadFirstImage(){
	var formData = new FormData($("#firstPicForm")[0]);
	$.ajax({
		type : "post",
		url : "${path}/siteArticle/uploadFirstImage.html",
		dataType : "json",
		data : formData,
		async : false,
		cache: false,
        contentType: false,
        processData: false,
		success : function(data) {
			if(data.ajax_status == "ajax_status_success"){
				$("#firstPic").find("img").attr("src",data.targetPath);
				$("#imageUrl").val(data.picUrl);
				$("#firstPic").show();
			}else{
				alert(data.msg);
			}
			return false;
		},
		error : function(XMLHttpRequest, textStatus, errorThrown){
          alert("出错了！");
       }
	});
	return false;;
}

//提交
function add(){
	$("#nodetypeform").submit();
}
</script>	
</body>
</html>
